package lab03.test07;
import java.io.*;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
public class Test {
    public static void main(String[] args) {
        File f = new File("E:\\book.zip");
        File dir = new File("E:\\book");
        byte b[] = new byte[100];
        dir.mkdir();
        try {
            ZipInputStream zipInputStream = new ZipInputStream(new FileInputStream(f));
            ZipEntry zipEntry = null;
            while ((zipEntry = zipInputStream.getNextEntry()) != null) {
                File file = new File(dir, zipEntry.getName());
                FileOutputStream fileOutputStream = new FileOutputStream(file);
                int n = -1;
                System.out.println(file.getAbsolutePath() + "的内容");
                while ((n = zipInputStream.read(b, 0, 100)) != -1) {
                    String str = new String(b, 0, n);
                    System.out.println(str);
                    fileOutputStream.write(b, 0, n);
                }
                fileOutputStream.close();
            }
        } catch (FileNotFoundException e1) {
            e1.printStackTrace();
        } catch (IOException e1) {
            e1.printStackTrace();
        }
    }
}
